<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> 
<%@page import="com.wxisme.ssm.po.Album" %>
<%@page import="com.wxisme.ssm.po.Photo" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
	<meta name="author" content="Luka Cvrk - www.solucija.com" />
	<meta name="description" content="Site Description" />
	<meta name="keywords" content="site, keywords" />
	<meta name="robots" content="index, follow" />
	<link rel="stylesheet" type="text/css" media="screen" href="css/style.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="css/side.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="css/button.css" />
	<title>welcome</title>
	
    <%
	String username = (String)session.getAttribute("username");
	if(username == null) {
		response.sendRedirect(basePath + "login.jsp");
	}
	%> 
	
	<!-- 读取用户相册信息 -->
    <%
    
    	//读取头像信息
    	String head = (String) session.getAttribute("head");
    	
	    //读取用户的此相册信息
		Map<Album, List<Photo>> userLoadingMap = (Map<Album, List<Photo>>) session.getAttribute("userLoadingMap");
		
		//判断是否是下载转过来的页面
		
		String zipPath = (String) request.getAttribute("zipPath");
		
		if(zipPath != null) {
			String pathes = basePath + zipPath;
			response.sendRedirect(pathes);
		}
		
	%>

  </head>
  
  <body>
  
	<div class="backwhite">
	<div class="header">
		<div id="search">
			<form action="">
				<fieldset>
					<input type="text" class="field" value="" placeholder="搜索"/>
					<input type="submit" class="buttons" value="" />
				</fieldset>
			</form>
		</div>
		<ul id="menu">
			<li><a href="welcome.jsp"><font face="Microsoft YaHei">首页</font></a></li>
			<!-- <li><a href="login.jsp">登录</a></li> -->
			<!-- <li><a href="register.jsp">注册</a></li> -->
			<li><a href="about.jsp"><font face="Microsoft YaHei">关于</font></a></li>
			<li><a href="photowall.jsp"><font face="Microsoft YaHei">照片墙</font></a></li>
			<li><a class="current" href="#"><font face="Microsoft YaHei">个人中心</font></a></li>
			<li>
			<form action="${pageContext.request.contextPath}/logout.action" method="post">
			<div class="logout">
			<input class="inputbutton" type="submit" name="submitlogout" value="退出/切换"/>
		    </div>
			</form>
			</li>
		</ul>
	</div>


		<div class="side">
		<br/>
		<br/>
		<br/>
		<br/>
		<form action="${pageContext.request.contextPath}/queryUserInfo.action" method="post">
		&nbsp;&nbsp;
		<input style="width:100px; height:100px; border-radius:50%;"; name="submit" type="image" src="<%=basePath+head %>"value="个人信息"/>
		</form>
		<br />
		<form action="${pageContext.request.contextPath}/queryFriends.action" method="post">
		<input class="button button-rounded button-flat-primary button-large" type="submit" value="共享空间"/>
		</form>
		<br />
		<br />
		<br />
		
		<a class="button button-rounded button-flat-primary button-large" href="batchAction.jsp">批量管理</a>
		
		<br />
		<br />
		<br />
		<form action="">
		<input class="button button-rounded button-flat-primary button-large" type="submit" value="我的家谱"/>
		</form>
  		</div>
  		<div class="main">
  		
  		
  			<br />
			<br />
			<div class="noNextLine">
			
			<a href="createAlbum.jsp" class="button button-pill button-primary">创建相册</a>
			
			&nbsp;&nbsp;&nbsp;&nbsp;
  			
			<a href="uploadPhoto.jsp" class="button button-pill button-primary">上传照片</a>
			
			</div>
			
			
			<!-- 展示图片 -->
			
			<!--遍历所有的图片并展示  -->
			<br />
			<%
			StringBuilder imgPath = new StringBuilder();
			for(Album album : userLoadingMap.keySet()) {
			    List<Photo> photoList = userLoadingMap.get(album);
			    
			    if(photoList.size() != 0) {
			    	imgPath.append(basePath + "imgdata/" + username + "file/");
					imgPath.append(album.getPathName() + "/" + photoList.get(0).getPathName());
			    
			    }
			    
			    else {
			    	imgPath.append(basePath + "images/" + "nophoto.jpg");
			    }
			%>
			
			<div class="albumBlock">
			<a href="photoDisplay.jsp?albumPath=<%=album.getPathName() %>">
				<img src=<%=imgPath.toString()%> width="150" height="150">
			</a><br />
			<%=album.getAlbumName() %><br/>
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<%=album.getPhotoNumber() %>
			</div>
			<%
				imgPath.delete(0, imgPath.length());
			}
			 %>
			
  		<!-- 分享到代码 -->
  		<div style="float:right;margin-top:600px">
  			<div class="bshare-custom icon-medium-plus">
			<a title="分享到QQ空间" class="bshare-qzone"></a>
			<a title="分享到新浪微博" class="bshare-sinaminiblog"></a>
			<a title="分享到人人网" class="bshare-renren"></a>
			<a title="分享到腾讯微博" class="bshare-qqmb"></a>
			<a title="分享到网易微博" class="bshare-neteasemb"></a>
			<a title="更多平台" class="bshare-more bshare-more-icon more-style-addthis"></a>
			<span class="BSHARE_COUNT bshare-share-count">0</span>
			</div>
			<script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/buttonLite.js#style=-1&amp;uuid=&amp;pophcol=2&amp;lang=zh"></script>
			<script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/bshareC0.js"></script>
  		
  		</div>
		
  		</div>
		
	</div>
	

	<div id="promo">
		<div class="wrap">
		<!--
			<div class="col">
				<img id="featured" src="images/featured.gif" alt="Featured Image" />
			</div>
	     -->
			
			<div id="footer">
				 <p><a href="#" target="_blank">关于</a>|免责声明：部分素材来自互联网，如有侵权请告知。|欢迎交流：850885154@qq.com</p>
				<p>Copyright &copy; 2015 &minus; 王旭 &minus; Design: &minus; <a href="http://www.cnblogs.com/wxisme/" target="_blank">wxisme</a></p>
			</div>
		</div>
	</div>
	
</body>
</html>
